<template>
	<view class="logins">
		<nav-bar isBack title="授权登录"></nav-bar>
		
		<!-- 顶部 -->
		<view class="login">			
			<view class="login_top">				
				<image :src="`${baseImg}/static/ryzLogo/logo-2.png`"></image>				
				<view class="login-name">融易装</view>				
				<view class="login-cont">我们需要您的授权，已关联融易装账号</view>			
			</view>		
		</view>
		<!-- 登录 -->
		<view class="login_btn">
			<template v-if="qyLoginType">
				<button class="weixin" @click="isDefaults" v-if="isDefault==0"><text>企业微信授权登录</text></button>
				<button class="weixin" v-if="isDefault==1" @click="qyLogin"><text>企业微信授权登录</text></button>
			</template>
			<template v-else>
				<button class="weixin" @click="isDefaults" v-if="isDefault==0"><text>微信授权登录</text></button>
				<button class="weixin" v-if="isDefault==1" @click="getUserPhone"><text>微信授权登录</text></button>
			</template>
			<view class="phone" @click="isDefaults" v-if="isDefault==0"><text>手机号授权登录</text></view>
			<view class="phone" @click="phonelogin()" v-if="isDefault==1" ><text>手机号授权登录</text></view>
		</view>
		<view class="radio-cell">
		    <label class="radio">
		        <radio @click="radioChange" :checked="isDefault==1" style="transform: scale(0.75);" color="#3D444B" :data-checked="isDefault"></radio>我已阅读并同意
		    </label>
			<text @click="agent">《用户授权协议》</text>
		</view>
		 <view v-if="openid" class="alert" >
		      <view class="auth">
		        <view class="apply">
		          <span class="">需要获取您的手机权限</span>
		          <p>(请开启手机权限)</p>
		        </view>
		        <button class="confirm" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">确认</button>
		      </view>
		 </view>
	</view>
</template>

<script>
import navBar from "@/components/navBar/navBar.vue"
import service_enter from '@/service/enter.js'
import URL from '@/config/url.js'


export default {
	components: { navBar },
	
	data() {
		return {
			baseImg:this.$static,
			isDefault:1,
			// 登录信息
			token: null,           // token
			isBindMobile: null,    // 是否绑定手机号
			userMobile: null,      // 用户手机号
			userId: null,          // 用户userId
			role:'',
			openid:'',
			sid:'',
			nickName:'',
			avatarUrl:'',
			count:'',
			qyLoginType:false,
			// rootStatus:true,//是否有权限进入管理页面（针对被移除的创业精英）
			
			miniType:'', //是否外部小程序（ 中灿/药箱 ）跳转过来提现的标识---OtherMiniCashOut
		}
	},
	
	onLoad(options) {
		let token = this.$store.state.index.token
		let app = getApp();
		this.miniType = app.globalData.miniType;
		if(token){
			uni.navigateTo({
				url: 'pages/mall/index/index',
			});
		}
		//#ifdef MP-WEIXIN
			const sinfo = wx.getSystemInfoSync();
			console.log(sinfo,'信息')
			if(sinfo.environment == 'wxwork'){
				this.qyLoginType = true
			}
		//#endif
	},
	
	methods: {
		phonelogin(){
			uni.navigateTo({
				url: '/pages_login/pages/login/phonelogin/index',
			});
		},
		agent(){
			uni.navigateTo({
				url: '/pages_login/pages/login/agreement/index',
			});
		},
		radioChange(t) {
			if(t.currentTarget.dataset.checked == 0){
				this.isDefault = 1
			}else{
				this.isDefault = 0
			}
		},
		
		isDefaults(){
			uni.showToast({ title: '您还未勾选授权协议！', icon: 'none' })
		},
		// 企业微信登录
		async qyLogin(){
			let that = this
			let single_id = uni.getStorageSync('single_id')
			let payStatus = uni.getStorageSync('payStatus')=='true'?true:false  //是否转发给用户支付
			let follow_id = uni.getStorageSync('follow_id')
			wx.qy.login({
				success:async res=>{
					console.log(res,'企业微信登录')
					if(res.code){
						await service_enter.qyLogin({
							code: res.code
						})
						.then(async res => {
							console.log(res,'企业微信登录+++')
							if (res.code == 1) {
								let data = res.data
								// let openid = res.data.openid
								// that.openid = openid
								let qy_userId = res.data.wxres.userid
								// if(res.data.is_has_headimg!=1 || res.data.is_has_nickname!=1){
								// 	if(uni.getUserProfile){
								// 		uni.getUserProfile({
								// 			desc:'Wexin',  // 这个参数是必须的
								// 			success:res=>{
								// 				console.log(res)
								// 				if(res.errMsg == 'getUserProfile:ok'){
								// 					let params = {
								// 						headimg:res.userInfo.avatarUrl,
								// 						nickname:res.userInfo.nickName
								// 					}
								// 					service_enter.changeUserInfo(params).then(res=>{
								// 						console.log(res,'更换用户信息')
								// 						if(res.code==1){}
								// 					})
								// 				}
								// 			},
								// 			fail:err=>{
								// 				console.log(err)
								// 			}
								// 		})
								// 	}
								// }
								console.log(qy_userId,'企业userid')
								if (qy_userId) {
									// let isBindMobile = data.bind_mobile_status == 1 ? true : false   // 用户是否绑定手机号
									let token = data.token.access_token
									let role = data.role
									let userId = data.user_id
									let sid = data.sid
									let count = data.count
									let qyUserId = data.qy_user_id
									let identityType = data.identity_type
									let isMaster = data.is_master
									let marketId = data.market_id
									let moduleType = data.type; //超级管家类型
									let moduleTeamId = data.steward_id; //超级管家团队id
									that.count = count
									// 保存数据
									that.token = token
									that.userId = userId
									that.role = role
									that.sid = sid
									that.$store.commit('index/SET_token', token)
									that.$store.commit('index/SET_role', role)
									that.$store.commit('index/SET_sid', sid)
									that.$store.commit('index/SET_tokenTime', Date.now())
									that.$store.commit('index/SET_userId', userId)
									that.$store.commit('index/SET_qyUserId', qyUserId)
									that.$store.commit('index/SET_identityType', identityType)
									that.$store.commit('index/SET_isMaster', isMaster)
									that.$store.commit('index/SET_storeCount', count)
									that.$store.commit('index/SET_marketId', marketId)
									that.$store.commit('index/SET_moduleType', moduleType)
									that.$store.commit('index/SET_moduleTeamId', moduleTeamId)
									
									await that.getAllRoot()
									that.$utils.hideLoading()
									if(follow_id){ //申请成为创客精英
										uni.reLaunch({
											url:`/pagesOne/distri/bandEntre/bindEntre?follow_id=${follow_id}`
										})
									}else if(single_id){ //修改优惠未登录时登陆完跳转
										if(payStatus){
											console.log(payStatus)
											console.log(payStatus===true)
											uni.reLaunch({
												url:`/pagesGuide/shopGuide/userPay/userPay?single_id=${single_id}`
											})
										}else{
											uni.reLaunch({
												url:`/pagesGuide/shopGuide/guideList/guideList?single_id=${single_id}`
											})
										}
										
									}else{
										if(that.role==''){
											// uni.reLaunch({
											// 	url: '/pages/enter/index/index'
											// });
											service_enter.getEnterStatus(userMobile).then(res=>{
												console.log(res,'roerole')
												if(res.code==1){
													if(res.data.type==0){ //没有入驻
														uni.reLaunch({
															url: '/pages/enter/index/index',
														});
													}else if(res.data.type==1){
														// 申请中
														if (res.data.status === 0) {
															// this.enterGet = 'null'   // 下次重新获取审核状态
															uni.reLaunch({ url: "/pages/enter/index/audit" })
														}
														// 申请通过
														else if (res.data.status === 1) {
															uni.reLaunch({ url: "/pages/enter/index/success"})
														}
														// 申请失败
														else if (res.data.status === 2) {
															uni.reLaunch({ url: "/pages/enter/index/fail?reason=" + res.data.reason })
														}
													}else if(res.data.type==2){
														// 申请中
														if (res.data.status === 0) {
															// this.enterGet = 'null'   // 下次重新获取审核状态
															uni.reLaunch({ url: "/pagesOne/distri/bandEntre/success" })
														}
														// 申请通过
														else if (res.data.status === 1) {
															uni.reLaunch({ url: "/pagesOne/distri/index/index"})
														}
														// 申请失败
														else if (res.data.status === 2) {
															uni.reLaunch({ url: "/pagesOne/distri/bandEntre/fail?reason=" + res.data.reason })
														}
													}else if(res.data.type==3){//已入驻，跳转到商家首页
														uni.reLaunch({ url: "/pages/mall/newIndex/newIndex"})
													}else{//已成为创客，跳转到创客首页
														// if(!this.rootStatus){//被移除的创客精英（没有权限）
														// 	uni.switchTab({
														// 		url:'/pages/mall/index/index'
														// 	})
														// 	return
														// }
														uni.reLaunch({ url: "/pagesOne/distri/index/index"})
													}
												}
											})
										}else{
											if(count>1){
												console.log(count,'countcount')
												uni.reLaunch({
													url:'/pages/enter/selectStore/index'
												})
											}else{
												// uni.switchTab({
												// 	url: '/pages/mall/index/index',
												// });
												let to_id = uni.getStorageSync('to_id'); //超级管家邀请团队成员时的id
												let steward_id = uni.getStorageSync('to_steward_id'); //超级管家邀请团队成员时的团队id
												if(to_id){
													uni.reLaunch({
														url:`/pages_superHK/pages/team/bindSuperHK?to_id=${to_id}&steward_id=${steward_id}`
													})
													return
												}
												
												let router = this.$store.state.index.page?this.$store.state.index.page.ability:[]
												console.log(router,'、、、、、')
												if(router.findIndex(item=>item.route == 'adminIndex')!=-1){ //总后台
													uni.reLaunch({
														url:'/pages_admin/home/home'
													})
												}else if(router.findIndex(item=>item.route == 'shopIndex')!=-1){ //商家
													uni.reLaunch({
														url:'/pagesFour/home/home'
													})
												}else if(router.findIndex(item=>item.route == 'designerIndex')!=-1){ //设计师
													uni.reLaunch({
														url:'/pageTwo/home/home'
													})
												}else if(router.findIndex(item=>item.route == 'builderIndex')!=-1){ //施工队
													uni.reLaunch({
														url:'/pagesOne/constr/home/home'
													})
												}else if(router.findIndex(item=>item.route == 'decorationIndex')!=-1){ //装修公司
													uni.reLaunch({
														url:'/pages_decoration/home/home'
													})
												}else if(router.findIndex(item=>item.route == 'promoterIndex')!=-1){
													// if(uni.getUserProfile){
													// 	uni.getUserProfile({
													// 		desc:'Wexin',  // 这个参数是必须的
													// 		success:res=>{
													// 			console.log(res)
													// 			if(res.errMsg == 'getUserProfile:ok'){
													// 				uni.setStorageSync('userInfo',res.userInfo)
																	uni.reLaunch({
																		url:'/pagesOne/distri/index/index'
																	})
													// 			}
													// 		},
													// 		fail:err=>{
													// 			console.log(err)
													// 		}
													// 	})
													// }
												}else{
													uni.reLaunch({
														url:'/pages/enter/index/index'
													})
												}
											}
										}
									}
								}
								
							}
							else {
								that.$utils.hideLoading()
								that.$utils.showErr({ title: res.msg })
							}
						})
					}
				}
			})
		},
		
		// 微信登录
		async getUserPhone(){
			let that = this
			// that.$utils.showLoading()
			let single_id = uni.getStorageSync('single_id')
			let payStatus = uni.getStorageSync('payStatus')=='true'?true:false  //是否转发给用户支付
			let follow_id = uni.getStorageSync('follow_id')
			uni.getUserProfile({
			        desc: '用于完善会员资料',  
			        lang: 'zh_CN',  
			        success: e => {
						that.nickName=e.userInfo.nickName
						that.avatarUrl=e.userInfo.avatarUrl
		                that.$utils.login({
		                	success:async res => {
		                		await service_enter.getToken({ 
		                			code: res.code ,
		                			nickName:that.nickName,
		                			avatarUrl:that.avatarUrl,
		                			})
		                			.then(res => {
										console.log(res,'登录登录+++')
		                				if (res.code == 1) {
		                					let data = res.data
		                					let openid = res.data.openid
		                					that.openid = openid
		                					// 已绑定手机号 => 获取用户审核信息
		                					if (!openid) {
												if(res.data.is_has_headimg!=1 || res.data.is_has_nickname!=1){
													let params = {
														headimg:that.avatarUrl,
														nickname:that.nickName
													}
													service_enter.changeUserInfo(params).then(res=>{
														console.log(res,'更换用户信息')
														if(res.code==1){}
													})
												}
		                						let isBindMobile = data.bind_mobile_status == 1 ? true : false   // 用户是否绑定手机号
		                						let token = data.token.access_token
		                						let role = data.role
		                						let userId = data.user_id
		                						let userMobile = data.mobile
		                						let sid = data.sid
												let qyUserId = data.qy_user_id
												let identityType = data.identity_type
												let isMaster = data.is_master
												let count = data.count
												let marketId = data.market_id
												let moduleType = data.type; //超级管家类型
												let moduleTeamId = data.steward_id; //超级管家团队id
												that.count = count
		                						// 保存数据
		                						that.token = token
		                						that.isBindMobile = isBindMobile
		                						that.userMobile = userMobile
		                						that.userId = userId
		                						that.role = role
		                						that.sid = sid
		                						that.$store.commit('index/SET_token', token)
		                						that.$store.commit('index/SET_role', role)
		                						that.$store.commit('index/SET_sid', sid)
		                						that.$store.commit('index/SET_tokenTime', Date.now())
		                						that.$store.commit('index/SET_isBindMobile', isBindMobile)
		                						that.$store.commit('index/SET_userMobile', userMobile)
		                						that.$store.commit('index/SET_userId', userId)
												that.$store.commit('index/SET_qyUserId', qyUserId)
												that.$store.commit('index/SET_identityType', identityType)
												that.$store.commit('index/SET_isMaster', isMaster)
												that.$store.commit('index/SET_storeCount', count)
												that.$store.commit('index/SET_marketId', marketId)
												that.$store.commit('index/SET_moduleType', moduleType)
												that.$store.commit('index/SET_moduleTeamId', moduleTeamId)
		                						that.getAllRoot()
		                						that.$utils.hideLoading()
												if(that.miniType == 'OtherMiniCashOut'){ //其他小程序跳过来提现
													uni.reLaunch({
														url:'/pages_ZC_Wallet/pages/index'
													})
												}else if(follow_id){ //申请成为创客精英
		                							uni.reLaunch({
		                								url:`/pagesOne/distri/bandEntre/bindEntre?follow_id=${follow_id}`
		                							})
		                						}else if(single_id){ //修改优惠未登录时登陆完跳转
		                							if(payStatus){
		                								console.log(payStatus)
		                								console.log(payStatus===true)
		                								uni.reLaunch({
		                									url:`/pagesGuide/shopGuide/userPay/userPay?single_id=${single_id}`
		                								})
		                							}else{
		                								uni.reLaunch({
		                									url:`/pagesGuide/shopGuide/guideList/guideList?single_id=${single_id}`
		                								})
		                							}
		                							
		                						}else{
		                							if(that.role==''){
		                								// uni.reLaunch({
		                								// 	url: '/pages/enter/index/index',
		                								// });
														service_enter.getEnterStatus(userMobile).then(res=>{
															console.log(res,'roerole')
															if(res.code==1){
																if(res.data.type==0){ //没有入驻
																	uni.reLaunch({
																		url: '/pages/enter/index/index',
																	});
																}else if(res.data.type==1){
																	// 申请中
																	if (res.data.status === 0) {
																		// this.enterGet = 'null'   // 下次重新获取审核状态
																		uni.reLaunch({ url: "/pages/enter/index/audit" })
																	}
																	// 申请通过
																	else if (res.data.status === 1) {
																		uni.reLaunch({ url: "/pages/enter/index/success"})
																	}
																	// 申请失败
																	else if (res.data.status === 2) {
																		uni.reLaunch({ url: "/pages/enter/index/fail?reason=" + res.data.reason })
																	}
																}else if(res.data.type==2){
																	// 申请中
																	if (res.data.status === 0) {
																		// this.enterGet = 'null'   // 下次重新获取审核状态
																		uni.reLaunch({ url: "/pagesOne/distri/bandEntre/success" })
																	}
																	// 申请通过
																	else if (res.data.status === 1) {
																		uni.reLaunch({ url: "/pagesOne/distri/index/index"})
																	}
																	// 申请失败
																	else if (res.data.status === 2) {
																		uni.reLaunch({ url: "/pagesOne/distri/bandEntre/fail?reason=" + res.data.reason })
																	}
																}else if(res.data.type==3){//已入驻，跳转到商家首页
																	uni.reLaunch({ url: "/pages/mall/newIndex/newIndex"})
																}else{//已成为创客，跳转到创客首页
																	// if(!this.rootStatus){//被移除的创客精英（没有权限）
																	// 	uni.switchTab({
																	// 		url:'/pages/mall/index/index'
																	// 	})
																	// 	return
																	// }
																	uni.reLaunch({ url: "/pagesOne/distri/index/index"})
																}
															}
														})
		                							}else{
														if(count>1){
															console.log(this.$store.state.index.page,'page')
															uni.reLaunch({
																url:'/pages/enter/selectStore/index?mobile='+userMobile
															})
														}else{
															
															let to_id = uni.getStorageSync('to_id'); //超级管家邀请团队成员时的id
															let steward_id = uni.getStorageSync('to_steward_id'); //超级管家邀请团队成员时的团队id
															if(to_id){
																uni.reLaunch({
																	url:`/pages_superHK/pages/team/bindSuperHK?to_id=${to_id}&steward_id=${steward_id}`
																})
																return
															}
															// uni.switchTab({
															// 	url: '/pages/mall/index/index',
															// });
															let router = this.$store.state.index.page?this.$store.state.index.page.ability:[]
															console.log(router,'、、、、、')
															if(router.findIndex(item=>item.route == 'adminIndex')!=-1){ //总后台
																uni.reLaunch({
																	url:'/pages_admin/home/home'
																})
															}else if(router.findIndex(item=>item.route == 'shopIndex')!=-1){ //商家
																uni.reLaunch({
																	url:'/pagesFour/home/home'
																})
															}else if(router.findIndex(item=>item.route == 'designerIndex')!=-1){ //设计师
																uni.reLaunch({
																	url:'/pageTwo/home/home'
																})
															}else if(router.findIndex(item=>item.route == 'builderIndex')!=-1){ //施工队
																uni.reLaunch({
																	url:'/pagesOne/constr/home/home'
																})
															}else if(router.findIndex(item=>item.route == 'decorationIndex')!=-1){ //装修公司
																uni.reLaunch({
																	url:'/pages_decoration/home/home'
																})
															}else if(router.findIndex(item=>item.route == 'promoterIndex')!=-1){
																// if(uni.getUserProfile){
																// 	uni.getUserProfile({
																// 		desc:'Wexin',  // 这个参数是必须的
																// 		success:res=>{
																// 			console.log(res)
																// 			if(res.errMsg == 'getUserProfile:ok'){
																// 				uni.setStorageSync('userInfo',res.userInfo)
																				uni.reLaunch({
																					url:'/pagesOne/distri/index/index'
																				})
																// 			}
																// 		},
																// 		fail:err=>{
																// 			console.log(err)
																// 		}
																// 	})
																// }
															}else{
																uni.reLaunch({
																	url:'/pages/enter/index/index'
																})
															}
														}
		                							}
		                						}
		                					}
		                					
		                				}
		                				else {
		                					that.$utils.hideLoading()
		                					that.$utils.showErr({ title: res.msg })
		                				}
		                			})
								}
							})
						}	
			    })			 
		},
		// 手机
		async getPhoneNumber(e){
			console.log(e,'手机')
			let that = this
			let single_id = uni.getStorageSync('single_id')
			let payStatus = uni.getStorageSync('payStatus')=='true'?true:false  //是否转发给用户支付
			let follow_id = uni.getStorageSync('follow_id')
				this.$utils.hideLoading()
				let encryptedData = e.detail.encryptedData
				let iv = e.detail.iv
				let page = e.currentTarget.dataset.page
				if (encryptedData && iv) {
					this.$utils.showLoading({ title: '绑定中...'})
					await service_enter.bindUserPhone({ 
						encryptedData:encryptedData, 
						iv:iv, 
						openid:this.openid,
						nickName:this.nickName,
						avatarUrl:this.avatarUrl,
						})
						.then(async res => {
							this.$utils.hideLoading()
						    if (res.code == 1) {
								console.log(res,'手机绑定')
								let data = res.data
								let mobile = res.data.mobile
								// 保存数据
								let token = data.token.access_token
								let role = data.role?data.role:''
								let userId = data.user_id
								let userMobile = data.mobile
								let sid = data.sid
								let qyUserId = data.qy_user_id
								let identityType = data.identity_type
								let isMaster = data.is_master
								let marketId = data.market_id?data.market_id:null
								let moduleType = data.type; //超级管家类型
								let moduleTeamId = data.steward_id; //超级管家团队id
								// 保存数据
								this.token = token
								this.userMobile = userMobile
								this.userId = userId
								this.role = role
								this.sid = sid
								this.$store.commit('index/SET_token', token)
								this.$store.commit('index/SET_role', role)
								this.$store.commit('index/SET_sid', sid)
								this.$store.commit('index/SET_tokenTime', Date.now())
								this.$store.commit('index/SET_userMobile', userMobile)
								this.$store.commit('index/SET_userId', userId)
								this.$store.commit('index/SET_qyUserId', qyUserId)
								this.isBindMobile = true
								this.userMobile = mobile	
								this.$store.commit('index/SET_isBindMobile', true)
								this.$store.commit('index/SET_userMobile', mobile)
								this.$store.commit('index/SET_identityType', identityType)
								this.$store.commit('index/SET_isMaster', isMaster)
								this.$store.commit('index/SET_storeCount', that.count)
								that.$store.commit('index/SET_marketId', marketId)
								that.$store.commit('index/SET_moduleType', moduleType)
								that.$store.commit('index/SET_moduleTeamId', moduleTeamId)
								await this.getAllRoot(userId)
								// 跳转页面
								if(that.miniType == 'OtherMiniCashOut'){ //其他小程序跳过来提现
									uni.reLaunch({
										url:'/pages_ZC_Wallet/pages/index'
									})
								}else if(follow_id){ //申请成为创客精英
									uni.reLaunch({
										url:`/pagesOne/distri/bandEntre/bindEntre?follow_id=${follow_id}`
									})
								}else if(single_id){ //修改优惠未登录时登陆完跳转
									if(payStatus){
										console.log(payStatus)
										console.log(payStatus===true)
										uni.reLaunch({
											url:`/pagesGuide/shopGuide/userPay/userPay?single_id=${single_id}`
										})
									}else{
										uni.reLaunch({
											url:`/pagesGuide/shopGuide/guideList/guideList?single_id=${single_id}`
										})
									}
								}else{
									if(this.role==''){
										// uni.navigateTo({
										// 	url: '/pages/enter/index/index',
										// });
										service_enter.getEnterStatus(userMobile).then(res=>{
											console.log(res,'roerole')
											if(res.code==1){
												if(res.data.type==0){ //没有入驻
													uni.reLaunch({
														url: '/pages/enter/index/index',
													});
												}else if(res.data.type==1){
													// 申请中
													if (res.data.status === 0) {
														// this.enterGet = 'null'   // 下次重新获取审核状态
														uni.reLaunch({ url: "/pages/enter/index/audit" })
													}
													// 申请通过
													else if (res.data.status === 1) {
														uni.reLaunch({ url: "/pages/enter/index/success"})
													}
													// 申请失败
													else if (res.data.status === 2) {
														uni.reLaunch({ url: "/pages/enter/index/fail?reason=" + res.data.reason })
													}
												}else if(res.data.type==2){
													// 申请中
													if (res.data.status === 0) {
														// this.enterGet = 'null'   // 下次重新获取审核状态
														uni.reLaunch({ url: "/pagesOne/distri/bandEntre/success" })
													}
													// 申请通过
													else if (res.data.status === 1) {
														uni.reLaunch({ url: "/pagesOne/distri/index/index"})
													}
													// 申请失败
													else if (res.data.status === 2) {
														uni.reLaunch({ url: "/pagesOne/distri/bandEntre/fail?reason=" + res.data.reason })
													}
												}else if(res.data.type==3){//已入驻，跳转到商家首页
													uni.reLaunch({ url: "/pages/mall/newIndex/newIndex"})
												}else{//已成为创客，跳转到创客首页
													// if(!this.rootStatus){//被移除的创客精英（没有权限）
													// 	uni.switchTab({
													// 		url:'/pages/mall/index/index'
													// 	})
													// 	return
													// }
													uni.reLaunch({ url: "/pagesOne/distri/index/index"})
												}
											}
										})
									}else{
										if(that.count>1){
											uni.reLaunch({
												url:'/pages/enter/selectStore/index?mobile='+userMobile
											})
										}else{
											let to_id = uni.getStorageSync('to_id'); //超级管家邀请团队成员时的id
											let steward_id = uni.getStorageSync('to_steward_id'); //超级管家邀请团队成员时的团队id
											if(to_id){
												uni.reLaunch({
													url:`/pages_superHK/pages/team/bindSuperHK?to_id=${to_id}&steward_id=${steward_id}`
												})
												return
											}
											// uni.switchTab({
											// 	url: '/pages/mall/index/index',
											// });
											let router = this.$store.state.index.page?this.$store.state.index.page.ability:[]
											console.log(router,'、、、、、')
											if(router.findIndex(item=>item.route == 'adminIndex')!=-1){ //总后台
												uni.reLaunch({
													url:'/pages_admin/home/home'
												})
											}else if(router.findIndex(item=>item.route == 'shopIndex')!=-1){ //商家
												uni.reLaunch({
													url:'/pagesFour/home/home'
												})
											}else if(router.findIndex(item=>item.route == 'designerIndex')!=-1){ //设计师
												uni.reLaunch({
													url:'/pageTwo/home/home'
												})
											}else if(router.findIndex(item=>item.route == 'builderIndex')!=-1){ //施工队
												uni.reLaunch({
													url:'/pagesOne/constr/home/home'
												})
											}else if(router.findIndex(item=>item.route == 'decorationIndex')!=-1){ //装修公司
												uni.reLaunch({
													url:'/pages_decoration/home/home'
												})
											}else if(router.findIndex(item=>item.route == 'promoterIndex')!=-1){
												// if(uni.getUserProfile){
												// 	uni.getUserProfile({
												// 		desc:'Wexin',  // 这个参数是必须的
												// 		success:res=>{
												// 			console.log(res)
												// 			if(res.errMsg == 'getUserProfile:ok'){
												// 				uni.setStorageSync('userInfo',res.userInfo)
																uni.reLaunch({
																	url:'/pagesOne/distri/index/index'
																})
												// 			}
												// 		},
												// 		fail:err=>{
												// 			console.log(err)
												// 		}
												// 	})
												// }
											}else{
												uni.reLaunch({
													url:'/pages/enter/index/index'
												})
											}
										}
										
										// if(this.role=='shop'){
										// 	uni.navigateTo({
										// 		url:'/pagesFour/home/home'
										// 	})
										// }
									}
								}
							}
							else {
								console.log('2222')
								this.$utils.showErr({ title: res.msg })
								// uni.navigateTo({
								// 	url: '/pages/enter/index/index',
								// });
							}
						})
				}
		},
		
		// 所有权限
		async getAllRoot(){
			let params = {
				user_id:this.$store.state.index.userId,
				page:1,
				pagesize:10
			}
			await this.$api.allRoot(params).then(res=>{
				console.log(res,'所有权限')
				if(res.code==1){
					let page = res.data
					this.$store.commit('index/SET_page', page)
				}
				// else if(res.code==-9){
				// 	this.rootStatus = false
				// }
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.logins{
	width: 100vw;height: 100vh;background: #fff;display: flex;flex-flow: column;
}
 .login{
	 padding-top: 88rpx;
	 padding-bottom: 20rpx;
	 .login_top{
		 text-align: center;
		 image{
			 display: block;
			 margin: auto;
			 width: 250rpx;
			 height: 250rpx;
		 }
		 .login-name{
			 font-size: 36rpx;
			 font-weight: bold;
			 color: #0A0605;
			 padding: 20rpx;
		 }
		 .login-cont{
			font-size: 28rpx;
			color: #505050; 
		 }
	 }
 }
 .login_btn{
	padding: 70rpx 50rpx;
	 .weixin{
		 line-height: 88rpx;
		 border-radius: 44rpx;
		 text-align: center;
		 background: #3D444B;
		 font-size: 36rpx;
		 color: #fff;
		 text{
			display: inline-block;
			 line-height: 88rpx;
			 padding-left: 60rpx;
			 background: url(@/static/login/weixin.png) no-repeat left center;
			 background-size: 48rpx;
		 }
	 }
	 .phone{
	 		 line-height: 88rpx;
	 		 border-radius: 44rpx;
	 		 text-align: center;
	 		 border: 1px #505050 solid;
	 		 font-size: 36rpx;
	 		 color: #505050;
			 margin-top: 30rpx;
	 		 text{
	 			display: inline-block;
	 			 line-height: 88rpx;
	 			 padding-left: 60rpx;
	 			 background: url(@/static/login/phone.png) no-repeat left center;
	 			 background-size: 48rpx;
	 		 }
	 }
 }
 .radio-cell{
	 text-align: center;
	 color: #A0A0A0;
	 text{
		 color: #505050;
	 }
 }
 .alert{
     position: fixed;
     top: 0;
     right: 0;
     bottom: 0;
     left: 0;
     overflow: hidden;
     outline: 0;
     -webkit-overflow-scrolling: touch;
     background-color: rgb(0, 0, 0);  
     filter: alpha(opacity=60);  
     background-color: rgba(0, 0, 0, 0.6); 
     z-index: 9999;
     .auth{
       position: absolute;
       top: 50%;
       left: 50%;
       width: 80%;
       height: 340rpx;
       border-radius: 20rpx;
	   overflow: hidden;
       transform:translate(-50%,-50%);
       background: #fff;
       display: flex;
       flex-direction: column;
       .apply{
         margin: 0rpx auto;
         padding: 60rpx 40rpx;
         flex:1;
         display: flex;
         flex-direction: column;
         align-items: center;
         justify-content: space-between;
         font-size: 34rpx;
         color:rgb(34,34,34);
         p{
           font-size:30rpx
         }
       }
       .confirm{
         border-top: 1rpx solid rgb(221,221,221);
         text-align: center;
         height: 100rpx;
         width: 100%;
         line-height: 100rpx;
         font-size: 34rpx;
         color:rgb(255,145,37);
       }
     }
   }
</style>